package com.ling.pl.security.feign;

import com.ling.pl.security.model.DefaultUrlVO;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Collection;
import java.util.List;
import java.util.Map;

/**
 * @author bo.wang
 */
@RequestMapping("/defaultRole")
@FeignClient(name = "LING-CLOUD-BASE")
public interface DefaultRoleService extends BaseDefaultRoleService {

    @RequestMapping(value = "/refreshUrlSecurityMetadata", method = RequestMethod.GET)
    public void refreshUrlSecurityMetadata();

    @RequestMapping(value = "/refreshAllSecurityMetadata", method = RequestMethod.GET)
    public void refreshAllSecurityMetadata();

    @RequestMapping(value = "/refreshComponentSecurityMetadata", method = RequestMethod.GET)
    public void refreshComponentSecurityMetadata();

    @RequestMapping(value = "/loadUrls", method = RequestMethod.GET)
    public List<DefaultUrlVO> loadUrls(@RequestParam("parentId") String parentId, @RequestParam("roleId") String roleId) throws Exception;

    @RequestMapping(value = "/saveRoleUrls", method = RequestMethod.PUT)
    public void saveRoleUrls(@RequestParam("roleId") String roleId, @RequestParam("ids") Collection<String> ids) throws Exception;

    @RequestMapping(value = "/loadMembers", method = RequestMethod.GET)
    public void loadMembers(Map<String, Object> parameter) throws Exception;

    @RequestMapping(value = "/changeGranted", method = RequestMethod.POST)
    public void changeGranted(Collection<Map<String, Object>> members) throws Exception;

    @RequestMapping(value = "/deleteRoleMember", method = RequestMethod.DELETE)
    public void deleteRoleMember(@RequestParam("memberId") String memberId) throws Exception;

    @RequestMapping(value = "/insertRoleMember", method = RequestMethod.PUT)
    public String insertRoleMember(@RequestParam("ids") Collection<String> ids, @RequestParam("type") String type, @RequestParam("roleId") String roleId) throws Exception;
}

